package com.yunzhou.controller.user;

import com.yunzhou.dto.LikeRecordDTO;
import com.yunzhou.entity.LikeRecord;
import com.yunzhou.result.Result;
import com.yunzhou.service.LikeRecordService;
import com.yunzhou.vo.LikeRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/likeRecord")
public class LikeRecordController {

    @Autowired
    private LikeRecordService likeRecordService;

    // 根据用户ID和操作类型获取点赞记录
    @GetMapping("getLikeRecordByUserIdAndOpType")
    public Result getLikeRecordByUserIdAndOpType(LikeRecordDTO likeRecordDTO){
        System.out.println("点赞记录"+likeRecordDTO);
        List<LikeRecord> likeRecordList = likeRecordService.getLikeRecordListByUserIdAndOpType(
                likeRecordDTO.getUserId(), likeRecordDTO.getOpType(), likeRecordDTO.getPageNum(), likeRecordDTO.getPageSize());
        Integer total = likeRecordService.getLikeRecordListTotalByUserIdAndOpType(likeRecordDTO.getUserId(), likeRecordDTO.getOpType());

        LikeRecordVO likeRecordVO = new LikeRecordVO();
        likeRecordVO.setLikeRecordList(likeRecordList);
        likeRecordVO.setTotal(total);
        System.out.println("点赞结果列v："+likeRecordVO);
        return Result.success(likeRecordVO);
    }

}
